package org.htmlparser.tags;

import org.htmlparser.lexer.Page;
import org.htmlparser.util.NodeList;
import org.htmlparser.util.SimpleNodeIterator;

public class FormTag extends CompositeTag
{
  public static final String GET = "GET";
  public static final String POST = "POST";
  static Class class$org$htmlparser$tags$InputTag;
  static Class class$org$htmlparser$tags$TextareaTag;
  private static final String[] mEndTagEnders;
  private static final String[] mIds;
  protected String mFormLocation = null;

  static
  {
    String[] arrayOfString1 = new String[1];
    arrayOfString1[0] = "FORM";
    mIds = arrayOfString1;
    String[] arrayOfString2 = new String[3];
    arrayOfString2[0] = "HTML";
    arrayOfString2[1] = "BODY";
    arrayOfString2[2] = "TABLE";
    mEndTagEnders = arrayOfString2;
  }

  static Class class$(String paramString)
  {
    Class localClass;
    try
    {
      localClass = Class.forName(paramString);
      return localClass;
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      throw new NoClassDefFoundError().initCause(localClassNotFoundException);
    }
  }

  public String extractFormLocn()
  {
    String str = getAttribute("ACTION");
    if (str == null)
      str = "";
    while (true)
    {
      do
        return str;
      while (getPage() == null);
      str = getPage().getAbsoluteURL(str);
    }
  }

  public String[] getEndTagEnders()
  {
    return mEndTagEnders;
  }

  public String[] getEnders()
  {
    return mIds;
  }

  public NodeList getFormInputs()
  {
    Class localClass;
    if (class$org$htmlparser$tags$InputTag == null)
    {
      localClass = class$("org.htmlparser.tags.InputTag");
      class$org$htmlparser$tags$InputTag = localClass;
    }
    while (true)
    {
      return searchFor(localClass, true);
      localClass = class$org$htmlparser$tags$InputTag;
    }
  }

  public String getFormLocation()
  {
    if (this.mFormLocation == null)
      this.mFormLocation = extractFormLocn();
    return this.mFormLocation;
  }

  public String getFormMethod()
  {
    String str = getAttribute("METHOD");
    if (str == null)
      str = "GET";
    return str;
  }

  public String getFormName()
  {
    return getAttribute("NAME");
  }

  public NodeList getFormTextareas()
  {
    Class localClass;
    if (class$org$htmlparser$tags$TextareaTag == null)
    {
      localClass = class$("org.htmlparser.tags.TextareaTag");
      class$org$htmlparser$tags$TextareaTag = localClass;
    }
    while (true)
    {
      return searchFor(localClass, true);
      localClass = class$org$htmlparser$tags$TextareaTag;
    }
  }

  public String[] getIds()
  {
    return mIds;
  }

  public InputTag getInputTag(String paramString)
  {
    label65: InputTag localInputTag2;
    InputTag localInputTag1 = null;
    int i = 0;
    SimpleNodeIterator localSimpleNodeIterator = getFormInputs().elements();
    while (true)
    {
      String str;
      do
      {
        if ((!(localSimpleNodeIterator.hasMoreNodes())) || (i != 0))
          break label65;
        localInputTag1 = (InputTag)localSimpleNodeIterator.nextNode();
        str = localInputTag1.getAttribute("NAME");
      }
      while ((str == null) || (!(str.equalsIgnoreCase(paramString))));
      i = 1;
    }
    if (i != 0)
      localInputTag2 = localInputTag1;
    while (true)
    {
      return localInputTag2;
      localInputTag2 = null;
    }
  }

  public TextareaTag getTextAreaTag(String paramString)
  {
    label65: TextareaTag localTextareaTag2;
    TextareaTag localTextareaTag1 = null;
    int i = 0;
    SimpleNodeIterator localSimpleNodeIterator = getFormTextareas().elements();
    while (true)
    {
      String str;
      do
      {
        if ((!(localSimpleNodeIterator.hasMoreNodes())) || (i != 0))
          break label65;
        localTextareaTag1 = (TextareaTag)localSimpleNodeIterator.nextNode();
        str = localTextareaTag1.getAttribute("NAME");
      }
      while ((str == null) || (!(str.equals(paramString))));
      i = 1;
    }
    if (i != 0)
      localTextareaTag2 = localTextareaTag1;
    while (true)
    {
      return localTextareaTag2;
      localTextareaTag2 = null;
    }
  }

  public void setFormLocation(String paramString)
  {
    this.mFormLocation = paramString;
    setAttribute("ACTION", paramString);
  }

  public String toString()
  {
    return "FORM TAG : Form at " + getFormLocation() + "; begins at : " + getStartPosition() + "; ends at : " + getEndPosition();
  }
}